import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15

Page {
    width: 640
    height: 380

    header: Label {
        text: qsTr("GPU Load")
        font.pixelSize: Qt.application.font.pixelSize * 2
        padding: 10
    }

    Rectangle {
        width: 240
        height: 150
        color: "#332121"
        anchors.centerIn: parent
        Rectangle {
            anchors.top: parent.top
            Layout.row: 0
            ProgressBar {
                id: loadPercentBar
                x: 27
                y: 8
                value: 0.5
            }
        }

        Rectangle {
            Layout.row: 1
            Label {
                id: loadPercentText
                text: SystemUtils.gpuLoadRead()
                font.pixelSize: Qt.application.font.pixelSize * 3
                anchors.verticalCenterOffset: 74
                anchors.horizontalCenterOffset: 117
                anchors.centerIn: parent
                Timer {
                    id: loadReadTimer
                    interval: 500
                    running: true
                    repeat: true
                    onTriggered: {
                        loadPercentText.text = SystemUtils.gpuLoadRead()
                        //console.log("gpu load:" + loadPercentText.text)
                    }
                }
            }
        }
    }
}
